package com.dingwen.treasure.kettle.controller;

import com.dingwen.treasure.kettle.base.controller.BaseViewController;
import com.dingwen.treasure.kettle.base.vo.Result;
import com.dingwen.treasure.kettle.service.FileService;
import com.dingwen.treasure.kettle.vo.FileVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 　FileController
 * 　@author dingwen
 * 　@date 2022/8/21
 */
@Api(tags = "转换、作业文件API")
@RestController
@Slf4j
@RequestMapping("file")
public class FileController implements BaseViewController {

    @Resource
    private FileService fileService;

    @ApiOperation(value = "获取指定目录下的转换、作业列表")
    @ApiImplicitParam(name = "directoryId", value = "目录Id")
    @GetMapping("/{directoryId}")
    @Cacheable(cacheNames = "file", key = "#root.methodName.concat(':').concat(#directoryId)")
    public Result<List<FileVo>> getFileList(@PathVariable("directoryId") String directoryId) {
        return success(fileService.getFileList(directoryId));
    }
}
